<?php

use yii\helpers\Html;
use common\models\CategoryGroup;
use yii\widgets\ActiveForm;
use kartik\select2\Select2;
use yii\helpers\ArrayHelper;
use yii\bootstrap\Alert;


/* @var $this yii\web\View */
/* @var $model common\models\Category */

$this->title = '申请创建揭示板';
$this->params['breadcrumbs'][] = ['label' => 'Categories', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-create main pd20">

    <h1><?= Html::encode($this->title) ?></h1>

    <?php if($msg):?>
    <?php
        Alert::begin([
            'options' => [
                'class' => 'alert-warning',
            ],
        ]);

        echo $msg;

        Alert::end();

        ?>
    <?php else : ?>
    <div class="category-form">

        <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>



        <?= $form->field($model, 'name')->textInput(['maxlength' => 20])->label("分类名") ?>

        <?= $form->field($model, 'group_id')->widget(Select2::className(),[
            'data' => ArrayHelper::map(CategoryGroup::find()->all(),'id','name') ,
            'language' => 'en',
            'options' => ['placeholder' => '请选择分组(必选)'],
            'pluginOptions' => [
                'allowClear' => true
            ]
        ])->label("分类组")  ?>


        <?= $form->field($model, 'keywords')->textInput(['maxlength' => 100])->label("关键词") ?>

        <?= $form->field($model, 'description')->textarea(['maxlength' => 255])->label("描述信息") ?>


        <?= $form->field($model, 'thumb')->fileInput(['maxlength' => 255])->label("分类背景图") ?>

        <?= $form->field($model, 'logo')->fileInput(['maxlength' => 255])->label("分类LOGO") ?>

        <div class="form-group">
            <?= Html::submitButton( '申请创建' , ['class' => 'btn btn-primary']) ?>
        </div>

        <?php ActiveForm::end(); ?>

    </div>
<?php endif?>

</div>
